Skip to content

test: run cli tests in top level npm test#825

Merged
virkt25 merged 2 commits into
masterfrom
cli-tests
Jan 3, 2018
Merged

test: run cli tests in top level npm test#825
virkt25 merged 2 commits into
masterfrom
cli-tests

Conversation

@virkt25

@virkt25 virkt25 commented Jan 2, 2018

Copy link
Copy Markdown
Contributor

Description

CLI Tests aren't run as part of top level npm test. Test count before change was 609. After this change it is 694.

Related issues

  • connect to <link_to_referenced_issue>

Checklist

  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide

@bajtos

bajtos commented Jan 2, 2018

Copy link
Copy Markdown
Member

I am fine with this change as a short-term fix, but wouldn't it better to fix the layout of CLI test folder to follow the convention we have everywhere else, namely "unit", "integration" and "acceptance" folders?

@kjdelisle kjdelisle left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the CLI tests aren't following our monorepo layout, that tells me something fishy is going on...

Comment thread package.json
"pretest": "npm run build:current",
"test": "node packages/build/bin/run-nyc npm run mocha",
"mocha": "node packages/build/bin/select-dist mocha --opts test/mocha.opts \"packages/*/DIST/test/**/*.js\"",
"mocha": "node packages/build/bin/select-dist mocha --opts test/mocha.opts \"packages/*/DIST/test/**/*.js\" \"packages/cli/test\"",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there no dist folder for the CLI tests? It should follow the existing pattern in the current command (packages/cli/dist/test/**/*.js)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kjdelisle I think the CLI cannot use TypeScript because it's a Yeoman generator under the hood, which has implications on the project layout. One more reason for getting rid of Yeoman! See #844

@virkt25

virkt25 commented Jan 2, 2018

Copy link
Copy Markdown
Contributor Author

CLI is written in JS not TS! So there's no build for it, which means there is no dist folder for it.

@raymondfeng

Copy link
Copy Markdown
Contributor

@virkt25 Please check why CI fails.

Comment thread package.json Outdated
"build:current": "lerna run --loglevel=silent build:current",
"pretest": "npm run build:current",
"pretest": "npm run build:current && npm run cli:link",
"cli:link": "cd packages/cli && npm link",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we do this?

@kjdelisle kjdelisle Jan 2, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with the cli:link command, but not having it added to pretest. This means that any time someone runs tests, they're going to lose their existing global installation of the CLI and have it replaced with the locally-linked one. I expect this would cause havoc for contributors down the line.

@kjdelisle kjdelisle left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the alteration to pretest, IMO.

Comment thread package.json Outdated
"build:current": "lerna run --loglevel=silent build:current",
"pretest": "npm run build:current",
"pretest": "npm run build:current && npm run cli:link",
"cli:link": "cd packages/cli && npm link",

@kjdelisle kjdelisle Jan 2, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with the cli:link command, but not having it added to pretest. This means that any time someone runs tests, they're going to lose their existing global installation of the CLI and have it replaced with the locally-linked one. I expect this would cause havoc for contributors down the line.

@virkt25

virkt25 commented Jan 2, 2018

Copy link
Copy Markdown
Contributor Author

I'm testing this right now to see if this fixes the issue with tests failing on Windows based on http://yeoman.io/authoring/

I'll ping the team if it works and is ready for review.

@virkt25 virkt25 changed the title test: run cli tests in top level npm test [WIP] test: run cli tests in top level npm test Jan 2, 2018
Comment thread package.json Outdated
"build:current": "lerna run --loglevel=silent build:current",
"pretest": "npm run build:current && npm run cli:link",
"cli:link": "cd packages/cli/generators && npm link && cd ../../..",
"cli:link": "cd packages/cli/generators/app && npm link && cd ../controller && npm link && ../extension && npm link && ../project && npm link && cd ../../..",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is completely wrong. Can you explain?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note we don't depend on global installation of generators as @loopback/cli does not use yo.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I'll have to see if I can get my hands on a windows machine as I see a lot of tests failing on AppVeyor with the following message:

Error: You don't seem to have a generator with the name “loopback4:C:\projects\loopback-next\packages\cli\generators\app” installed.
But help is on the way:
You can see available generators via npm search yeoman-generator or via http://yeoman.io/generators/. 
Install them with npm install generator-loopback4:C:\projects\loopback-next\packages\cli\generators\app.
To see all your installed generators run yo without any arguments. Adding the --help option will also show subgenerators. 
If yo cannot find the generator, run yo doctor to troubleshoot your system.
      at Environment.create (packages\cli\node_modules\yeoman-environment\lib\environment.js:368:9)
      at Object.exports.testSetUpGen (packages\cli\test\test-utils.js:15:14)
      at Context.it (packages\cli\test\base-generator.js:15:29)

@raymondfeng

Copy link
Copy Markdown
Contributor

I think I know what causes the Windows build issue now. There are a few places that we use / as a separator to split paths.

We need to use path.sep as the separator so that it works on all platforms.

@virkt25 virkt25 changed the title [WIP] test: run cli tests in top level npm test test: run cli tests in top level npm test Jan 2, 2018
@virkt25
virkt25 merged commit 6474763 into master Jan 3, 2018
@virkt25
virkt25 deleted the cli-tests branch January 3, 2018 00:16
virkt25 added a commit that referenced this pull request Jan 3, 2018
* test: run cli tests in top level npm test

* fix(cli): use path.sep to be platform agnostic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants